<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/Main' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-row>
        <el-col :span='7'>
          <el-input placeholder="请输入内容" clearable v-model="FormData.query" class="input-with-select">
            <el-button slot="append" icon="el-icon-search" @click='getData'></el-button>
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="TableData" style="width: 100%" border>
        <el-table-column label='#' type='index'></el-table-column>
        <el-table-column label='订单编号' prop='order_number'></el-table-column>
        <el-table-column label='订单价格' prop='order_price' width='150'></el-table-column>
        <el-table-column label='是否付款' prop='order_pay' width='80'>
           <template #default='scope'>
            <el-tag type="info" v-if='scope.row.pay_status === "0"'>未付款</el-tag>
            <el-tag type="success" v-else>以付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column label='是否发货' prop='is_send' width='80'></el-table-column>
        <el-table-column label='下单时间' prop='create_time' width='130'></el-table-column>
        <el-table-column label='操作' width='70'>
          <template >
            <el-button type="success" size='mini' icon="el-icon-location-outline" @click='showPosition'></el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page='FormData.pagenum'
        :page-sizes="[10, 20, 30, 40]"
        :page-size="FormData.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </el-card>
    <el-dialog
      title="修改地址"
      :visible.sync="editDialog"
      width="50%">
      <el-timeline>
        <el-timeline-item
          v-for="(activity, index) in activities"
          :key="index"
          :timestamp="activity.time">
          {{activity.context}}
        </el-timeline-item>
      </el-timeline>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editDialog = false">取 消</el-button>
        <el-button type="primary" @click="editDialog = false">分 配</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      FormData:{
        query:'',
        pagenum:1,
        pagesize:10
      },
      TableData:[],
      total:0,
      editDialog:false,
      activities:[],
    }
  },
  methods:{
    async getData() {
      let res = await this.axios.get('/orders', { params: this.FormData })
      if( res.meta.status !== 200 ) return this.pop.error( res.meta.msg )
      this.TableData = res.data.goods
      this.total = res.data.total
    },
    handleSizeChange( size ) {
      this.FormData.pagesize = size
      this.getData()
    },
    handleCurrentChange( num ) {
      this.FormData.pagenum = num
      this.getData()
    },
    showPosition(  ) {
      this.getPosition(  )
      this.editDialog = true 
    },
    async getPosition(  ) {
      let res = await this.axios.get(`/kuaidi/1106975712662`)
      if( res.meta.status !== 200 ) return this.pop.error( res.meta.msg )
      this.activities = res.data
    },
  },
  created() {
    this.getData()
  }
}
</script>

<style>

</style>